.class public Les/g4;
.super Ljava/lang/Object;
.source "AdbConnection.java"

# interfaces
.implements Ljava/io/Closeable;


# instance fields
.field private a:Ljava/net/Socket;

.field private b:I

.field private c:Ljava/io/InputStream;

.field d:Ljava/io/OutputStream;

.field private e:Ljava/lang/Thread;

.field private f:Z

.field private g:Z

.field private h:I

.field private i:Les/h4;

.field private j:Z

.field private k:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap<",
            "Ljava/lang/Integer;",
            "Les/j4;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method private constructor <init>()V
    .locals 1

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 2
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    iput-object v0, p0, Les/g4;->k:Ljava/util/HashMap;

    const/4 v0, 0x0

    .line 3
    iput v0, p0, Les/g4;->b:I

    .line 4
    invoke-direct {p0}, Les/g4;->n()Ljava/lang/Thread;

    move-result-object v0

    iput-object v0, p0, Les/g4;->e:Ljava/lang/Thread;

    return-void
.end method

.method static synthetic a(Les/g4;I)I
    .locals 0

    .line 3
    iput p1, p0, Les/g4;->h:I

    return p1
.end method

.method public static a(Ljava/net/Socket;Les/h4;)Les/g4;
    .locals 1
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .line 4
    new-instance v0, Les/g4;

    invoke-direct {v0}, Les/g4;-><init>()V

    .line 5
    iput-object p1, v0, Les/g4;->i:Les/h4;

    .line 6
    iput-object p0, v0, Les/g4;->a:Ljava/net/Socket;

    .line 7
    invoke-virtual {p0}, Ljava/net/Socket;->getInputStream()Ljava/io/InputStream;

    move-result-object p1

    iput-object p1, v0, Les/g4;->c:Ljava/io/InputStream;

    .line 8
    invoke-virtual {p0}, Ljava/net/Socket;->getOutputStream()Ljava/io/OutputStream;

    move-result-object p1

    iput-object p1, v0, Les/g4;->d:Ljava/io/OutputStream;

    const/4 p1, 0x1

    .line 9
    invoke-virtual {p0, p1}, Ljava/net/Socket;->setTcpNoDelay(Z)V

    return-object v0
.end method

.method static synthetic a(Les/g4;)Ljava/lang/Thread;
    .locals 0

    .line 1
    iget-object p0, p0, Les/g4;->e:Ljava/lang/Thread;

    return-object p0
.end method

.method static synthetic a(Les/g4;Z)Z
    .locals 0

    .line 2
    iput-boolean p1, p0, Les/g4;->g:Z

    return p1
.end method

.method static synthetic b(Les/g4;)Ljava/io/InputStream;
    .locals 0

    .line 1
    iget-object p0, p0, Les/g4;->c:Ljava/io/InputStream;

    return-object p0
.end method

.method static synthetic b(Les/g4;Z)Z
    .locals 0

    .line 2
    iput-boolean p1, p0, Les/g4;->j:Z

    return p1
.end method

.method static synthetic c(Les/g4;)Z
    .locals 0

    .line 1
    iget-boolean p0, p0, Les/g4;->g:Z

    return p0
.end method

.method static synthetic c(Les/g4;Z)Z
    .locals 0

    .line 2
    iput-boolean p1, p0, Les/g4;->f:Z

    return p1
.end method

.method static synthetic d(Les/g4;)Ljava/util/HashMap;
    .locals 0

    .line 1
    iget-object p0, p0, Les/g4;->k:Ljava/util/HashMap;

    return-object p0
.end method

.method static synthetic e(Les/g4;)Z
    .locals 0

    .line 1
    iget-boolean p0, p0, Les/g4;->j:Z

    return p0
.end method

.method static synthetic f(Les/g4;)Les/h4;
    .locals 0

    .line 1
    iget-object p0, p0, Les/g4;->i:Les/h4;

    return-object p0
.end method

.method static synthetic g(Les/g4;)I
    .locals 0

    .line 1
    iget p0, p0, Les/g4;->h:I

    return p0
.end method

.method private g()V
    .locals 2

    .line 2
    iget-object v0, p0, Les/g4;->k:Ljava/util/HashMap;

    invoke-virtual {v0}, Ljava/util/HashMap;->values()Ljava/util/Collection;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-eqz v1, :cond_0

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Les/j4;

    .line 3
    :try_start_0
    invoke-virtual {v1}, Les/j4;->close()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    nop

    goto :goto_0

    .line 4
    :cond_0
    iget-object v0, p0, Les/g4;->k:Ljava/util/HashMap;

    invoke-virtual {v0}, Ljava/util/HashMap;->clear()V

    return-void
.end method

.method static synthetic h(Les/g4;)V
    .locals 0

    .line 1
    invoke-direct {p0}, Les/g4;->g()V

    return-void
.end method

.method private n()Ljava/lang/Thread;
    .locals 2

    .line 1
    new-instance v0, Ljava/lang/Thread;

    new-instance v1, Les/g4$a;

    invoke-direct {v1, p0, p0}, Les/g4$a;-><init>(Les/g4;Les/g4;)V

    invoke-direct {v0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    return-object v0
.end method


# virtual methods
.method public a(Ljava/lang/String;)Les/j4;
    .locals 4
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/UnsupportedEncodingException;,
            Ljava/io/IOException;,
            Ljava/lang/InterruptedException;
        }
    .end annotation

    .line 10
    iget v0, p0, Les/g4;->b:I

    add-int/lit8 v0, v0, 0x1

    iput v0, p0, Les/g4;->b:I

    .line 11
    iget-boolean v1, p0, Les/g4;->f:Z

    if-eqz v1, :cond_3

    .line 12
    monitor-enter p0

    .line 13
    :try_start_0
    iget-boolean v1, p0, Les/g4;->g:Z

    if-nez v1, :cond_0

    .line 14
    invoke-virtual {p0}, Ljava/lang/Object;->wait()V

    .line 15
    :cond_0
    iget-boolean v1, p0, Les/g4;->g:Z

    if-eqz v1, :cond_2

    .line 16
    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_1

    .line 17
    new-instance v1, Les/j4;

    invoke-direct {v1, p0, v0}, Les/j4;-><init>(Les/g4;I)V

    .line 18
    iget-object v2, p0, Les/g4;->k:Ljava/util/HashMap;

    invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    invoke-virtual {v2, v3, v1}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 19
    iget-object v2, p0, Les/g4;->d:Ljava/io/OutputStream;

    invoke-static {v0, p1}, Les/i4;->a(ILjava/lang/String;)[B

    move-result-object p1

    invoke-virtual {v2, p1}, Ljava/io/OutputStream;->write([B)V

    .line 20
    iget-object p1, p0, Les/g4;->d:Ljava/io/OutputStream;

    invoke-virtual {p1}, Ljava/io/OutputStream;->flush()V

    .line 21
    monitor-enter v1

    .line 22
    :try_start_1
    invoke-virtual {v1}, Ljava/lang/Object;->wait()V

    .line 23
    monitor-exit v1
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 24
    invoke-virtual {v1}, Les/j4;->isClosed()Z

    move-result p1

    if-nez p1, :cond_1

    return-object v1

    .line 25
    :cond_1
    new-instance p1, Ljava/net/ConnectException;

    const-string v0, "Stream open actively rejected by remote peer"

    invoke-direct {p1, v0}, Ljava/net/ConnectException;-><init>(Ljava/lang/String;)V

    throw p1

    :catchall_0
    move-exception p1

    .line 26
    :try_start_2
    monitor-exit v1
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    throw p1

    .line 27
    :cond_2
    :try_start_3
    new-instance p1, Ljava/io/IOException;

    const-string v0, "Connection failed"

    invoke-direct {p1, v0}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw p1

    :catchall_1
    move-exception p1

    .line 28
    monitor-exit p0
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    throw p1

    .line 29
    :cond_3
    new-instance p1, Ljava/lang/IllegalStateException;

    const-string v0, "connect() must be called first"

    invoke-direct {p1, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw p1
.end method

.method public b()V
    .locals 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;,
            Ljava/lang/InterruptedException;
        }
    .end annotation

    .line 3
    iget-boolean v0, p0, Les/g4;->g:Z

    if-nez v0, :cond_2

    .line 4
    iget-object v0, p0, Les/g4;->d:Ljava/io/OutputStream;

    invoke-static {}, Les/i4;->a()[B

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write([B)V

    .line 5
    iget-object v0, p0, Les/g4;->d:Ljava/io/OutputStream;

    invoke-virtual {v0}, Ljava/io/OutputStream;->flush()V

    const/4 v0, 0x1

    .line 6
    iput-boolean v0, p0, Les/g4;->f:Z

    .line 7
    iget-object v0, p0, Les/g4;->e:Ljava/lang/Thread;

    invoke-virtual {v0}, Ljava/lang/Thread;->start()V

    .line 8
    monitor-enter p0

    .line 9
    :try_start_0
    iget-boolean v0, p0, Les/g4;->g:Z

    if-nez v0, :cond_0

    .line 10
    invoke-virtual {p0}, Ljava/lang/Object;->wait()V

    .line 11
    :cond_0
    iget-boolean v0, p0, Les/g4;->g:Z

    if-eqz v0, :cond_1

    .line 12
    monitor-exit p0

    return-void

    .line 13
    :cond_1
    new-instance v0, Ljava/io/IOException;

    const-string v1, "Connection failed"

    invoke-direct {v0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw v0

    :catchall_0
    move-exception v0

    .line 14
    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0

    .line 15
    :cond_2
    new-instance v0, Ljava/lang/IllegalStateException;

    const-string v1, "Already connected"

    invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v0
.end method

.method public close()V
    .locals 1
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .line 1
    iget-object v0, p0, Les/g4;->e:Ljava/lang/Thread;

    if-nez v0, :cond_0

    return-void

    .line 2
    :cond_0
    iget-object v0, p0, Les/g4;->a:Ljava/net/Socket;

    invoke-virtual {v0}, Ljava/net/Socket;->close()V

    .line 3
    iget-object v0, p0, Les/g4;->e:Ljava/lang/Thread;

    invoke-virtual {v0}, Ljava/lang/Thread;->interrupt()V

    .line 4
    :try_start_0
    iget-object v0, p0, Les/g4;->e:Ljava/lang/Thread;

    invoke-virtual {v0}, Ljava/lang/Thread;->join()V
    :try_end_0
    .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0

    :catch_0
    return-void
.end method

.method public d()Z
    .locals 1

    .line 2
    iget-boolean v0, p0, Les/g4;->f:Z

    return v0
.end method
